	function setCookie(key,value,time){
		var mydate =new Date();
		mydate.setDate(mydate.getDate()+time);
		document.cookie=key+"="+encodeURI(value)+";expires="+mydate.toGMTString();
	}
	
	function getCookie(key){
		var str=document.cookie;
		var arr=str.split("; ");
		for(var i=0;i<arr.length;i++){
			var newArr=arr[i].split("=");
			if(newArr[0]==key){
				return decodeURI(newArr[1]);
			}
		};
	}

	
$(function(){
	$(".second_right input").blur(function(){
		if($(this).is(".text")){
			if(this.value==""){
				$(".error").show();
			}else{
				$(".error").hide();
			}
		}
		if($(this).is(".mima")){
			if(this.value==""||this.value.length<6||this.value.length>20){
				$(".error").show();
			}else{
				$(".error").hide();
			}
		}
		
	});
	
	$(".sub").click(function(){
		if($(".text").val()&&$(".mima").val()){
			var a=confirm("是否确认浏览器记住用户名与密码？");
			if(a){
				setCookie("text1",$(".text").val(),5);
				setCookie("text2",$(".mima").val(),5);
			}
			window.open("index.html");
			$(".error").hide();
		}else{
			$(".error").show();
		}
	});
	getCookie("text1");
	getCookie("text2");

	if(getCookie($(".text").val())){
		$(".text").val(getCookie("text1"));
	}
	$(".mima").click(function(){
		if($(".text").val()==getCookie("text1")){
			$(".mima").val(getCookie("text2"));	
		}
	});
	
	
//side效果
	var timer_men;
	$("#side .side_men").mouseover(function(){
		clearInterval(timer_men);
		$("#side .men").css("display","block").animate({"right":"36"},200)
	}).mouseout(function(){
		timer_men=setTimeout(function(){
			$("#side .men").css({"right":"50px","display":"none"});
		},300);
	});
	$("#side .men").mouseover(function(){
		$(this).css({"right":"36px","display":"block"});
		clearInterval(timer_men);
	}).mouseout(function(){
		$(this).css({"right":"50px","display":"none"});
	});

	$("#side .side_cart").toggle(function(){
		$(this).css({"background":"#616"});
		$("#side .cart").css("display","block").animate({"right":"36"},200);
	},function(){
		$("#side .cart").css("display","block").animate({"right":"-336"},200);
		$(this).css({"background":"#000"});
	});
	
	var timer_start;
	$("#side .side_start").mouseover(function(){
		$("#side .start").css("display","block").animate({"right":"36"},200);
	}).mouseout(function(){
		timer_start=setTimeout(function(){
			$("#side .start").css({"right":"50px","display":"none"});
		},300);
	});
	$("#side .start").mouseover(function(){
		clearInterval(timer_start);
		$(this).css({"right":"36px","display":"block"});
	}).mouseout(function(){
		$(this).css({"right":"50px","display":"none"});
	});
	
	var timer_history;
	$("#side .side_history").mouseover(function(){
		$("#side .history").css("display","block").animate({"right":"36"},200);
	}).mouseout(function(){
		timer_history=setTimeout(function(){
			$("#side .history").css({"right":"50px","display":"none"});
		},300);
	});
	$("#side .history").mouseover(function(){
		clearInterval(timer_history);
		$(this).css({"right":"36px","display":"block"});
	}).mouseout(function(){
		$(this).css({"right":"50px","display":"none"});
	});
	
	var timer_news;
	$("#side .side_news").mouseover(function(){
		$("#side .news").css("display","block").animate({"right":"36"},200);
	}).mouseout(function(){
		timer_news=setTimeout(function(){
			$("#side .news").css({"right":"50px","display":"none"});
		},300);
	});
	$("#side .news").mouseover(function(){
		clearInterval(timer_news);
		$(this).css({"right":"36px","display":"block"});
	}).mouseout(function(){
		$(this).css({"right":"50px","display":"none"});
	});

	var timer_kefu;
	$("#side .side_kefu").mouseover(function(){
		$("#side .kefu").css("display","block").animate({"right":"36"},200);
	}).mouseout(function(){
		timer_kefu=setTimeout(function(){
			$("#side .kefu").css({"right":"50px","display":"none"});
		},300);
	});
	$("#side .kefu").mouseover(function(){
		clearInterval(timer_kefu);
		$(this).css({"right":"36px","display":"block"});
	}).mouseout(function(){
		$(this).css({"right":"50px","display":"none"});
	});
	
	var timer_ewm;
	$("#side .side_ewm").mouseover(function(){
		$("#side .ewm").css("display","block").animate({"right":"36"},200);
	}).mouseout(function(){
		timer_ewm=setTimeout(function(){
			$("#side .ewm").css({"right":"50px","display":"none"});
		},300);
	});
	$("#side .ewm").mouseover(function(){
		clearInterval(timer_ewm);
		$(this).css({"right":"36px","display":"block"});
	}).mouseout(function(){
		$(this).css({"right":"50px","display":"none"});
	});
	
	$(".side_up").click(function(){
		timer1=setInterval(function(){
			var 
				scrollT=document.documentElement.scrollTop||document.body.scrollTop,
				
				speed=Math.round((0-scrollT)/10);
			document.documentElement.scrollTop=document.body.scrollTop=scrollT+speed;
			
			if(speed==0){
				clearInterval(timer1);
			}
		},30);
	});
});